home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / pcprl11.zip / LCP.DOC < prev    next >
Text File  |  1991-12-01  |  14KB  |  481 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.                         Linda Conversion Program
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.                    Parallel Computer Solutions, Inc.
  53.  
  54.                           November 30, 1991
  55.  
  56.  
  57. Copyright 1991 Parallel Computer Solutions. All Rights Reserved
  58.  
  59.  
  60. The terms and conditions governing the sale of Parallel Computer
  61. Solutions hardware products and the licensing of Parallel Computer
  62. Solutions software consist solely of those set forth in the written
  63. contracts between Parallel Computer Solutions and its customers. 
  64. No representation or other affirmation of facts contained in this
  65. publication, including but not limited to statements regarding
  66. capacity, response time, suitability for use or performance of
  67. products described herein shall be deemed to be a warranty by
  68. Parallel Computer Solutions for any purpose or give rise to any
  69. liability by Parallel Computer Solutions whatever.
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. No part of this document may be copied or reproduced in any form or
  81. by any means without the prior written consent of Parallel Computer
  82. Solutions. Information is subject to change without notice.
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90. Printed in the United States of America.
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100. Parallel Lan System is a copyright of Parallel Computer Solutions.
  101. Linda is a copyright of Scientific Computing Associates Inc. Turbo
  102. Pascal is a copyright of Borland International Inc.
  103.  
  104.  
  105.  
  106. Introduction
  107.  
  108.         The Parallel Lan System requires the use of the
  109. coordination language PCS-Linda is order to execute parallel
  110. programs.  The language itself is beyond these instructions for the
  111. conversion program.  Those wishing to get a feel for the Linda
  112. language used in the Parallel Lan System are directed to the manual
  113. A Guide to Parallel Programming Using PCS-Linda and the Parallel
  114. Lan System published by Parallel Computer Solutions.
  115.  
  116.  
  117. Purpose
  118.  
  119.         The Linda Conversion Program converts a program written
  120. using Turbo Pascal and PCS-Linda into pure Turbo Pascal.
  121. Thus allowing the Turbo compiler to compile the program.  This
  122. instruction document will describe the operation, limitations, and
  123. specifications of the conversion program.
  124.  
  125.  
  126.  
  127. Operation
  128.  
  129.         When started, the Linda Conversion Program ( LCP ) will
  130. blank the screen and produce the following display
  131.  
  132.  
  133.                         Parallel Lan System
  134.                       Linda Conversion Program
  135.  
  136.  
  137.  
  138.                 Enter name of file to be processed ->
  139.  
  140.  
  141.         LCP is waiting for the filename of the program to be
  142. converted. This file must end with the extension .PLS.  If the file
  143. is not found by LCP the message
  144.  
  145.                 File not found..
  146.  
  147. will be displayed and the program will exit.  If the file does
  148. exist, check your spelling and run the program again.  It is not
  149. necessary to include the extension when entering the name of the
  150. file.  It however, can be included if desired.
  151.  
  152.         Once LCP has found the file, it will inform you that its
  153. output will be named with an extension of .PAS.  The same initial
  154. name will be used.
  155.  
  156.      When LCP is finished with your program, it will display the
  157. message 
  158.  
  159.                 Finished!
  160.  
  161.  
  162. Parallel Lan System is a copyright of Parallel Computer Solutions.
  163. Linda is a copyright of Scientific Computing Associates Inc.
  164.  
  165.  
  166.         The new file can be compiled with Turbo Pascal and executed
  167. on the Parallel Lan System.
  168.  
  169.         Alternatively, the file to be converted can be included in
  170. the command line.  Thus to convert the file test.pls we would type
  171.  
  172.                 linda test
  173.  
  174.  
  175. Limitations
  176.  
  177.         The Linda Conversion Program will not produce any error
  178. messages. This has been left up to the Turbo Pascal compiler.  In
  179. order to make some sense of the resulting pascal code, the
  180. following examples are given.  The three examples will illustrate
  181. the different code that the LCP will produce.  The first example
  182. shows code generated for the in () and rd () instructions.  The
  183. second example shows the eval () instruction.  The third example
  184. will show the rdp () and inp () instructions.  A short
  185. explanatation will be given about the code for the out ()
  186. instruction.
  187.  
  188.  
  189. IN (); and RD ();
  190.  
  191.         The LCP, when given the Linda command
  192.  
  193.                 in ( 'stuff', a, &v, 1, 2 );
  194.  
  195. will produce the following Turbo Pascal code
  196.  
  197. { in ( 'stuff', a, &v, 1, 2 ); }
  198.  
  199. begin
  200. make_tuple( 5,'s','t','u','f','f',' ',' ',' ',' ',' ',' ',' ',' ','
  201. ',' ',' ', @a, sizeof ( a ), no,  @v sizeof ( v ), yes, 
  202. @anint[3], sizeof ( anint[3] ), yes, 
  203. @anint[4], sizeof ( anint[4] ), yes, 
  204. nil, 0, null, 
  205. nil, 0, null
  206.  ); 
  207.  
  208. anint[3] := 1;
  209. anint[4] := 2;
  210.  
  211. send_tuple (  _in );
  212. get_tuple ( pkt, plen );
  213. convert_to_tuple_made ( pkt, a_tuple );
  214. end;
  215.  
  216.  
  217. An Explanation
  218.  
  219.         Because this is the code that the Turbo Pascal Compiler
  220. will have to compile, we will go over what the statements do in the
  221. event that an error occurs in the middle of the code.
  222.  
  223.         The first eight lines appear to be a jumble of code but it
  224. is a single procedure call which assembles a tuple based on the information
  225. given to the procedure.  A procedure call was used to decrease the
  226. amount of code produced by the Linda Conversion Program.
  227.  
  228. make_tuple( 5,'s','t','u','f','f',' ',' ',' ',' ',' ',' ',' ',' ','
  229. ',' ',' ', @a, sizeof ( a ), no, @v, sizeof ( v ), yes,
  230. @anint[3], sizeof ( anint[3] ), yes,
  231. @anint[4], sizeof ( anint[4] ), yes,
  232. nil, 0, null,
  233. nil, 0, null
  234. );
  235.  
  236.   Several things can happen when the Turbo Pascal Compiler begins
  237. to compile this code.  The original command was
  238.  
  239.                 in ( 'stuff', a, &v, 1, 2 );
  240.  
  241. which tells use that we must have two variables a and v declared in
  242. the VAR section.  If an error occurs at either the @a/@v or the
  243. sizeof(a)/sizeof(v), check to make sure that you have declared the
  244. two variables.  Remember, if this tuple command is in the
  245. procedure to be sent to a worker, the variables must be declared
  246. local in the procedure and not global.  
  247.  
  248.         It is very important not to declare the variable array
  249. anint. This is a system array that is used during tuple
  250. transmission and is of no concern to the developer. Because we only
  251. used four of the six elements in the variable, the nil, 0, null
  252. entries will instruct the make_tuple procedure to handle these
  253. empty elements.
  254.  
  255.         After the appropriate operation have been performed in the
  256. tuple definition, the system will assign any actual numbers in the
  257. tuple to the system variable arrays.  We had two such actuals; 1
  258. and 2.
  259.  
  260.                 anint[4] := 2;
  261.                 anint[3] := 1;
  262.  
  263.   
  264.         The next three instructions do the actual transmission and
  265. reception of tuples.  First we have to send the tuple request to
  266. the master
  267.  
  268.                 send_tuple ( _in );
  269.  
  270.         This instruction will use a system user-defined set
  271. element; _in. This instructs the sending routine to tell the master
  272. that this tuple is to be treated as an IN tuple.  If this instruction
  273. was a RD, then we would use the system user-defined set element RD
  274. instead of _in.
  275.  
  276.         Because the tuple is an IN tuple, we are guaranteed a tuple
  277. in return ( at least we hope ).  The procedure get_tuple will
  278. receive a tuple and put it into a special buffer.
  279.  
  280.           get_tuple ( pkt, plen );
  281.  
  282.         This buffer doesn't really contain a tuple.  It contains a
  283. long sequence of bytes which must be translated and formed into the
  284. tuple we sent to the match for the match.  The
  285. convert_to_tuple_made procedure performs this conversion.
  286.  
  287.           convert_to_tuple_made ( pkt );
  288.  
  289.         If we look at the original IN instruction, we see that only
  290. the a variable will be given a value from the new tuple we
  291. received. The actuals 1, 2, and variable v were used as matching
  292. elements only.
  293.  
  294.         All of the procedure and most of the variable are system
  295. related. They have been coded in the work and both units that have
  296. to be USESed into the program.
  297.  
  298.  
  299. EVAL ();
  300.  
  301.   The eval instruction that we are going to decode is
  302.  
  303.                 eval ( 'work', &adder );
  304.  
  305.   This instruction becomes
  306.  
  307. { eval ( 'work', &adder ); }
  308. begin
  309. make_tuple(4,'w','o','r','k',' ',' ',' ',' ',' ',' ',' ',' ',' ','
  310. ',' ', ' ', @segofs, sizeof ( segofs ), yes,  @adder , sizeof (
  311. adder  ), data, 
  312. nil, 0, null,
  313. nil, 0, null,
  314. nil, 0, null,
  315. nil, 0, null
  316.  );
  317.  
  318.  
  319. find_procedure_length ( @adder, integer(a_tuple^.elements[2].size
  320. )); send_tuple ( eval );  end;
  321.  
  322. after the Linda Conversion Program does its work.  Everything is
  323. the same except the statements after the assignment of the name of
  324. the tuple. The make_tuple statement includes as additional element
  325. that the original PCS-Linda instruction did not contain.  The
  326. variable segofs contains information about the developer the
  327. program is executing on.  It must be included with the eval tuple
  328. sent to the master but the software engineer doesn't need to know
  329. about it so the Linda Conversion Program inserts it for us.
  330.  
  331.         After our tuple has been made, we have to fill in one of
  332. the elements positions.  Notice in the statements for the
  333. make_tuple procedure call, the length of the procedure that is to
  334. be sent to the master is 0.  That would be of little use so a call
  335. must be made to the procedure find_procedure_length is order to
  336. find the exact length of the procedure to send.
  337.  
  338. find_procedure_length (@adder,integer(a_tuple^.elements[2].size ));
  339.  
  340.         This procedure will find the length of the procedure and
  341. assign it to the appropriate element size.  This is the end of the
  342. tuple formation so the tuple is sent to the master using the set
  343. element eval to instruct the master to treat this tuple as an eval
  344. tuple.
  345.  
  346.                 send_tuple ( a_tuple, eval );
  347.  
  348.  
  349. RDP (); and INP ();
  350.  
  351.         The RDP and INP instructions are a little different than
  352. the other instructions.  The name of the tuple and elements are
  353. formed the same as the RD and IN instruction but after that we have
  354. a choice of operations.  Remember that the form of the INP and RDP
  355. instructions is to assign them to a boolean variable such as the
  356. INP instruction
  357.  
  358. ok := inp ( 'stuff' ); 
  359.  
  360.   This instruction would be translated as
  361.  
  362. begin
  363. make_tuple(5,'s','t','u','f','f',' ',' ',' ',' ',' ',' ',' ',' ','
  364. ',' ',' ', nil, 0, null,  nil, 0, null, 
  365. nil, 0, null, 
  366. nil, 0, null, 
  367. nil, 0, null, 
  368. nil, 0, null
  369.  ); 
  370. send_tuple ( a_tuple, inp );
  371. get_tuple ( pkt, plen );
  372. if mem[seg(pkt^):ofs(pkt^)+17] = byte ( tuple_commands ( none ))
  373. then   ok  := false else
  374.   begin
  375.     ok  := true; 
  376.     convert_to_tuple_made ( pkt, a_tuple );
  377.   end;
  378. end;
  379.  
  380.         We are concerned with the code after a tuple is received
  381. from the master.  If the master does not find a match, a null tuple
  382. is returned to the requestor, otherwise, the matching tuple is
  383. returned.
  384.  
  385.  
  386.  
  387.      This code determines if the tuple received was null or not.
  388.  
  389. if mem[seg(pkt^):ofs(pkt^)+17] = byte ( tuple_commands ( none ))
  390. then   ok  := false else
  391.   begin
  392.     ok  := true; 
  393.     convert_to_tuple_made ( pkt, a_tuple );
  394.   end;
  395.  
  396.         A specific location inside of all tuples indicates the
  397. operation the master perform on the tuple.  If this case, if the
  398. operation was NONE, the tuple is null and the boolean variable must
  399. be assigned the value FALSE.  We must also make sure that no
  400. formals are given values in the null tuple.
  401.  
  402.         If the tuple is not null, the boolean variable is set to
  403. TRUE and the tuple is converted.  After which all memory allocated
  404. is released.
  405.  
  406.         The RDP and INP instructions have the additional boolean
  407. variable to worry about during compile time.  If this variable is
  408. not declared, Turbo Pascal will flag it.
  409.  
  410.  
  411. OUT ();
  412.  
  413.         The OUT instruction is treated as the RD and IN
  414. instructions except the statements
  415.  
  416.           get_tuple ( pkt, plen );
  417.           convert_to_tuple_made ( pkt );
  418.      
  419. are eliminated since an OUT instruction simply sends the tuple to
  420. the master to be put into tuple space.
  421.  
  422.  
  423. BEGIN END;
  424.  
  425.   All tuple commands are enclosed in a BEGIN END; pair.  This will
  426. cause an error when tuples are used in the following manner
  427.  
  428.                if a = 1 then
  429.                  out ( 'num', 1 );
  430.                else
  431.                  out ( 'num', 2 );
  432.  
  433. this code with generate
  434.  
  435.                if a = 1 then
  436. begin
  437. ---
  438. end;
  439.                else
  440. begin
  441. ---
  442. end;
  443.  
  444. The problem arises in the Turbo Pascal compiler which requires the
  445. statement preceding the else statement to be free of the ; symbol.
  446. This situation can easily be solved by adding a BEGIN END; pair in
  447. the original code.
  448.  
  449.                if a = 1 then
  450.                  begin
  451.                    out ( 'num', 1 );
  452.                  end
  453.                else
  454.                  out ( 'num', 2 );
  455.  
  456.  
  457. Skipped Linda Commands
  458.  
  459.         If your Linda commands are anything other that the
  460. following list and spelled any different, the LCP will not pick
  461. them up.
  462.  
  463.         in ();  out ();  rd ();  inp ();  rdp ();  eval ();  
  464.  
  465.         There must be a space between the Linda word and the (
  466. character. If there isn't, LCP will skip the command.  This will be
  467. fixed in a future release.
  468.  
  469.  
  470.  
  471. Problems
  472.  
  473.   Any problems encountered with the Linda Conversion Program should
  474. be directed to:
  475.  
  476.  
  477.                         Parallel Computer Solutions
  478.                         2112 Hancock Street #205
  479.                         Laramie, Wyoming 82070
  480.                         EMAIL gradecki@master.uwyo.edu
  481.